package com.eistert.java.algorithm.dijkstra;

/**
 * @Description:
 * @Author: ai
 * @create: 2023-04-26 10:53
 */
public class DijkstraAlgorithm {
    public static final int N = 65535; // 表示不可以连接

    public static void main(String[] args) {
        // 顶点集合
        char[] vertex = new char[]{'A', 'B', 'C', 'D', 'E', 'F', 'G'};

        // 初始化矩阵
        int[][] matrix = new int[vertex.length][vertex.length];
        matrix[0] = new int[]{N, 5, 7, N, N, N, 2};
        matrix[1] = new int[]{5, N, N, 9, N, N, 3};
        matrix[2] = new int[]{7, N, N, N, 8, N, N};
        matrix[3] = new int[]{N, 9, N, N, N, 4, N};
        matrix[4] = new int[]{N, N, 8, N, N, 5, 4};
        matrix[5] = new int[]{N, N, N, 4, 5, N, 6};
        matrix[6] = new int[]{2, 3, N, N, 4, 6, N};

        Graph graph = new Graph(vertex, matrix);

        // 测试, 看看图的邻接矩阵是否 ok
        graph.showGraph();

        // 测试迪杰斯特拉算法
        graph.dijkstra(2);

        graph.showDijkstra();
    }
}
